Skip to content

ref(night-shift): Use seer-project-settings helpers for project eligibility#112936

Open
chromy wants to merge 1 commit intomasterfrom
chromy/ref/night-shift-seer-project-settings
Open

ref(night-shift): Use seer-project-settings helpers for project eligibility#112936
chromy wants to merge 1 commit intomasterfrom
chromy/ref/night-shift-seer-project-settings

Conversation

@chromy
Copy link
Copy Markdown
Contributor

@chromy chromy commented Apr 14, 2026

Add a unified `bulk_read_preferences()` helper in `autofix/utils.py` that
returns `dict[int, SeerProjectPreference | None]` regardless of whether
preferences are read from Sentry DB or the Seer API. The helper checks the
`seer-project-settings-read-from-sentry` feature flag internally so callers
don't need to duplicate that branching logic.

Use the new helper in the night-shift cron's `_get_eligible_projects`,
replacing the direct `SeerProjectRepository` query. The
`autofix_automation_tuning != OFF` filter is preserved on top of the
preference check.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 14, 2026
@chromy chromy marked this pull request as ready for review April 14, 2026 18:11
@chromy chromy requested a review from a team as a code owner April 14, 2026 18:11
@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from d01fd09 to e704614 Compare April 14, 2026 19:50
@chromy chromy requested a review from a team as a code owner April 14, 2026 19:50
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e704614. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Backend Test Failures

Failures on f53c8b2 in this run:

tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_creates_project_preferenceslog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:228: in test_post_creates_project_preferences
    assert preferences == [
E   AssertionError: assert [{'autofix_au...3760544, ...}] == [{'automated_...3826080, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968173760544, 'project_id': 4557968173826080, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968173760544, 'project_id': 4557968173826080, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968173760544,
E               'project_id': 4557968173826080,
E               'repositories': [],
E           },
E       ]
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_updates_each_preference_field_independentlylog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:289: in test_post_updates_each_preference_field_independently
    assert preferences == [
E   AssertionError: assert [{'autofix_au...4940192, ...}] == [{'automated_...5005728, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968174940192, 'project_id': 4557968175005728, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968174940192, 'project_id': 4557968175005728, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968174940192,
E               'project_id': 4557968175005728,
E               'repositories': [],
E           },
E       ]

@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from e704614 to 8b8fe1d Compare April 14, 2026 19:59
@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from 8b8fe1d to a226560 Compare April 14, 2026 20:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Backend Test Failures

Failures on f3190e8 in this run:

tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_updates_each_preference_field_independentlylog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:289: in test_post_updates_each_preference_field_independently
    assert preferences == [
E   AssertionError: assert [{'autofix_au...4184736, ...}] == [{'automated_...4250272, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968234184736, 'project_id': 4557968234250272, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968234184736, 'project_id': 4557968234250272, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968234184736,
E               'project_id': 4557968234250272,
E               'repositories': [],
E           },
E       ]
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_creates_project_preferenceslog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:228: in test_post_creates_project_preferences
    assert preferences == [
E   AssertionError: assert [{'autofix_au...2939536, ...}] == [{'automated_...3005072, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968232939536, 'project_id': 4557968233005072, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968232939536, 'project_id': 4557968233005072, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968232939536,
E               'project_id': 4557968233005072,
E               'repositories': [],
E           },
E       ]

@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from a226560 to 99c5a91 Compare April 14, 2026 20:13
@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from 99c5a91 to b0f533f Compare April 14, 2026 20:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Backend Test Failures

Failures on 927853a in this run:

tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_updates_each_preference_field_independentlylog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:289: in test_post_updates_each_preference_field_independently
    assert preferences == [
E   AssertionError: assert [{'autofix_au...3167136, ...}] == [{'automated_...3232672, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968293167136, 'project_id': 4557968293232672, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968293167136, 'project_id': 4557968293232672, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968293167136,
E               'project_id': 4557968293232672,
E               'repositories': [],
E           },
E       ]
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py::OrganizationAutofixAutomationSettingsEndpointTest::test_post_creates_project_preferenceslog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/seer/endpoints/test_organization_autofix_automation_settings.py:228: in test_post_creates_project_preferences
    assert preferences == [
E   AssertionError: assert [{'autofix_au...2642848, ...}] == [{'automated_...2642848, ...}]
E     
E     At index 0 diff: {'organization_id': 4557968292642848, 'project_id': 4557968292642848, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None, 'autofix_automation_tuning': None} != {'organization_id': 4557968292642848, 'project_id': 4557968292642848, 'repositories': [], 'automated_run_stopping_point': 'open_pr', 'automation_handoff': None}
E     
E     Full diff:
E       [
E           {
E     +         'autofix_automation_tuning': None,
E               'automated_run_stopping_point': 'open_pr',
E               'automation_handoff': None,
E               'organization_id': 4557968292642848,
E               'project_id': 4557968292642848,
E               'repositories': [],
E           },
E       ]

@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from b0f533f to cade023 Compare April 14, 2026 20:58
…bility

Replace direct SeerProjectRepository queries in _get_eligible_projects
with bulk_read_preferences_from_sentry_db / bulk_get_project_preferences
behind the seer-project-settings-read-from-sentry feature flag, matching
the pattern used in context_engine_index and autofix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/TusCoPLrgCYHLxdSUeDTGIDPYU1f6BITAaO7rK6QDl0
@chromy chromy force-pushed the chromy/ref/night-shift-seer-project-settings branch from cade023 to 63d1544 Compare April 14, 2026 21:01
Copy link
Copy Markdown
Member

@srest2021 srest2021 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper looks good, thanks for writing this!

Only one nit, which is adding the tuning to SeerProjectPreference--Seer will drop the field when it gets included in writes, and the write preference helpers to Sentry DB won't write it either. Mind adding a clarifying comment to the write helpers? Or alternatively could just return tuples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants